<template>
  <div>
    <div class="form_wrap">
      <el-form label-width="150px" style="margin-top:10px">
        <el-row>
          <el-col :span="2">
            反馈信息:
          </el-col>
          <el-row>
            <el-col :span="4">
              <el-form-item class="posInput ts" label-width="0px">
                <el-select v-model="backMsg" :disabled="true">
                  <el-option
                    v-for="item in options"
                    :key="item.itemValue"
                    :label="item.itemText"
                    :value="item.itemValue"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xl="2" :lg="3" style="line-height: 20px;">
              <el-button
                @click="openDiaCharge"
                v-if="showChargeBtn && orderStatus == 4"
                >{{ chargeTitle }}</el-button
              >
            </el-col>
          </el-row>
        </el-row>
      </el-form>
    </div>
    <!--弹框-->
    <el-dialog
      title="修改信息"
      :visible.sync="dialogTableVisible"
      width="500px"
    >
      <el-form label-width="150px">
        <el-row>
          <el-col :span="24">
            <el-form-item class="posInput ts" label="反馈信息">
              <el-select v-model="diaBackMsg">
                <el-option
                  v-for="item in options"
                  :key="item.itemValue"
                  :label="item.itemText"
                  :value="item.itemValue"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <div class="dialog-footer">
          <el-button @click="dialogTableVisible = false">取 消</el-button>
          <el-button type="primary" @click="submitcharge">确 定</el-button>
        </div>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import {
  getProductUrl,
  getAstatus,
  getAccInfo,
  updateBackMsg
} from "../../../src/assets/js/api";
import { checkPermiss } from "../../assets/js/utlis";
export default {
  name: "FeedBack",
  data() {
    return {
      orderNumber: "",
      dialogTableVisible: false,
      //财务
      backMsg: "1",
      diaBackMsg: "1",
      chargeTitle: "修改",
      showdis: null,
      diaTitle: null,
      options: [],
      golbalPermissions: [],
      ProductUrl: "",
      orderStatus: null
    };
  },
  created() {
    this.golbalPermissions = localStorage.getItem("permissions").split(",");
    this.orderNumber = this.orderNumber = sessionStorage.getItem("orderNumber");
    this.classification();
    this.findProductUrl(this.orderNumber);
    this.getUpForm();
  },
  computed: {
    //财务信息添加按钮
    showChargeBtn: function() {
      return checkPermiss("business:fund:backMsg", this.golbalPermissions);
    }
  },
  methods: {
    //根据订单查询路由path路径
    findProductUrl(orderNumber) {
      getProductUrl({
        orderNumber: orderNumber
      }).then(res => {
        this.ProductUrl = res.data.productUrl;
        this.orderStatus = res.data.orderStatus;
      });
    },
    //获取各字典状态
    classification() {
      //获取是否状态
      getAstatus("payment_status").then(res => {
        this.options = res.data;
      });
      //获取银行分类
    },
    //根据订单号查询当前信息
    getUpForm() {
      getAccInfo(this.orderNumber).then(res => {
        this.backMsg = res.data.backMsg;
        this.diaBackMsg = JSON.parse(JSON.stringify(this.backMsg));
      });
    },
    openDiaCharge() {
      this.dialogTableVisible = true;
    },
    //反馈提交按钮
    submitcharge() {
      updateBackMsg({
        orderNumber: this.orderNumber,
        backMsg: this.diaBackMsg
      }).then(res => {
        if (res.code == 200) {
          this.getUpForm();
          this.chargeTitle = "修改";
          this.dialogTableVisible = false;
          this.$message.success(res.message);
        }
      });
    }
  }
};
</script>

<style scoped type="less">
.posInput {
  position: relative;
}
.pos {
  position: absolute;
  z-index: 2;
}
.pos.left {
  left: 10px;
}
.pos.right {
  right: 0;
}
.posInput ::v-deep .el-input__inner {
  padding: 0 50px 0 40px;
  text-align: center;
}
.posInput.ts ::v-deep .el-input__inner {
  padding-left: 25px;
}
.toBe {
  line-height: 35px;
}
.form_wrap ::v-deep .el-form-item,
.form_wrap ::v-deep .el-form-item__label,
.form_wrap ::v-deep .el-form-item__content,
.form_wrap ::v-deep .el-input,
.form_wrap ::v-deep .el-input__inner {
  height: 32px;
  line-height: 32px;
}
.form_wrap ::v-deep .el-form-item {
  margin-bottom: 5px;
}
.form_wrap ::v-deep .el-col {
  line-height: 32px;
}
.form_wrap ::v-deep .el-button {
  padding: 8px 20px;
}
.form_wrap ::v-deep.el-input__icon {
  line-height: 24px;
}
::v-deep .el-form-item__content {
  text-align: left;
}
.el-date-editor.el-input {
  width: auto;
}
</style>
